package skladowisko.utils;

import com.thoughtworks.xstream.XStream;
import java.io.FileInputStream;
import java.io.InputStream;
import skladowisko.Terminal;
import skladowisko.transport.Transport;

/**
 *
 * @author kedziers
 */
public class XStreamTerminalCreator implements ITerminalCreator, ITransportCreator{

    public Terminal wczytajTerminal(String nazwaPliku)
    {
        XStream xstream = new XStream();

        try
        {
        InputStream is = new FileInputStream(nazwaPliku);
        Terminal terminal = (Terminal)xstream.fromXML(is);
        return terminal;
        }
        catch(Exception e)
        {
            System.out.println(e.getMessage());
        }

        return null;
    }

    public Transport wczytajTransport(String nazwaPliku)
    {
        XStream xstream = new XStream();

        try
        {
        InputStream is = new FileInputStream(nazwaPliku);
        Transport transport = (Transport)xstream.fromXML(is);
        return transport;
        }
        catch(Exception e)
        {
            System.out.println(e.getMessage());
        }

        return null;
    }

}
